<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app">
      <ul>
        <li>小李</li>
        <li>中李</li>
        <li>老李</li>
      </ul>

      <ul>
        <!-- 
          v-for="(item, index) in 要遍历的数据"

          遍历的元素要求添加一个key属性，值是唯一的(稳定) 一般使用id
          key用来提升更新性能
         -->
        <li v-for="(person, index) in persons" :key="person.id">
          {{ person.name }} {{ index }}
        </li>
      </ul>

      <!-- <ul>
        <li v-for="(index, person) in persons">{{ index }} {{ person }}</li>
      </ul> -->
    </div>
    <script src="./js/vue.js"></script>
    <script>
      const vm = new Vue({
        data: {
          persons: [
            { id: 1, name: "小李" },
            { id: 2, name: "中李" },
            { id: 3, name: "老李" },
          ],
        },
      });
      vm.$mount("#app");
    </script>
  </body>
</html>
